package demo9;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Period;

public class test8 {
    public static void main(String[] args) {
        //当前本地 年月日
        LocalDateTime today = LocalDateTime.now();
        System.out.println(today);

        //生日的 年月日
        LocalDateTime birthDate = LocalDateTime.of(2000,1,1,0,00,00);
        System.out.println(birthDate);
        Duration duration = Duration.between(birthDate,today);

        System.out.println("相差的时间间隔对象："+duration);
        System.out.println("===========================");

        System.out.println(duration.toDays());//两个时间差的天数
        System.out.println(duration.toHours());//两个时间差的小时数
        System.out.println(duration.toMinutes());//两个时间差的分钟数
        System.out.println(duration.toMillis());//两个时间差的毫秒数
        System.out.println(duration.toNanos());//两个时间差的纳秒数
    }
}
